import 'amfe-flexible';
import Vue from 'vue';
import App from './App.vue';

import { router } from './router';
import store from './store/index.js';
import { Icon, Popup, Button, Toast, Dialog, ImagePreview } from 'vant';
import Navigation from 'vue-navigation';
// env拎出来，下面还要用 :localhost 、development
const NODE_ENV = process.env.NODE_ENV;
const VUE_APP_HOST = process.env.VUE_APP_HOST;


// 生产环境，本地服务去掉调试插件vConsole
if (VUE_APP_HOST !== 'prd' && NODE_ENV !== 'localhost') {
	let VConsole = require('vconsole');
	const vConsole = new VConsole();
	setTimeout(() => {
		vConsole.setSwitchPosition(20, 60);
	}, 0);
}

Dialog.setDefaultOptions({
	overlay: true,
	className: 'ems-mobile-dialog',
	confirmButtonColor: '#FFB403'
});
// 允许同时存在多个 Toast
Toast.allowMultiple(true);
// 将所有 loading Toast 设置为背景不可点击 (2.2.10 版本开始支持)
Toast.setDefaultOptions('loading', { forbidClick: true });

// 注册
Vue.use(Toast);
Vue.use(Icon);
Vue.use(Popup);
Vue.use(Button);
Vue.use(Dialog);
Vue.use(ImagePreview);
// 用于控制浏览器前进后退缓存
Vue.use(Navigation, {
	router,
	store
});

let vueOption = {
	router,
	store,
	render: h => h(App)
};
let app = new Vue(vueOption);
app.$mount('#app');
window.app = app;

app.env = VUE_APP_HOST;
app.isLocalhost = NODE_ENV === 'localhost';


